package pl.world
{
	import com.greensock.TweenNano;
	import pl.textures.Textures;
	import pl.textures.game.ISingleTexture;
	import pl.world.actors.proto.BaseActor;
	import starling.display.DisplayObject;
	import starling.display.Image;




	/**
	 * ...
	 * @author Bakudo
	 */
	public class DummyActor extends BaseActor
	{
		private var speedX:uint;
		private var speedY:uint;
		private var reverseSpeedXAt:uint;
		private var reverseSpeedYAt:uint;

		public function DummyActor( _x:uint, _y:uint, _type:uint, atlasID:uint,speed:Number )
		{
			speedX = 1 + Math.random() * 5;
			speedY = 1 + Math.random() * 5;

			reverseSpeedXAt = _x + 500 * Math.random() * 300;
			reverseSpeedYAt = _y + 500 * Math.random() * 300;

			super( _x, _y, _type, atlasID ,speed);
		}

		public function goto( px:uint, py:uint, time:Number = 1 ):void
		{
			TweenNano.to( this, time, {x:px, y:py, onUpdate:doUpdateView} );
		}

		override protected function doUpdateView():void
		{
			if (isRendered == true)
			{
				_display.x = isoX;
				_display.y = isoY;
			}
		}

		override public function processLogic():void
		{
			super.processLogic();
		}

		override public function get display():DisplayObject
		{
			if (_display == null)
			{
				var text:ISingleTexture = Textures.getSingleTexture( _texture );
				_display = new Image( text.texture );
				_pivotX = text.pivotX;
				_pivotY = text.pivotY;
				updateView = true;
			}
			return _display;
		}
		
		
		override public function cleanView():void
		{
			_display.dispose();
			_display = null;
		}
	}
}